﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

public struct HighScoreData
{
    public string[] Name;
    public int[] Score;
    public int[] Level;

    public int Count;

    public HighScoreData(int count)
    {
        Name = new string[count];
        Score = new int[count];
        Level = new int[count];

        Count = count;
    }

    public static void SaveHighScores(HighScoreData highscores)
    {
        string file = "highscores.xml";
        FileStream stream = File.Open(file, FileMode.OpenOrCreate);
        try
        {
            XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
            serializer.Serialize(stream, highscores);
        }
        finally
        {
            stream.Close();
        }
    }

    public static HighScoreData LoadHighScores()
    {
        HighScoreData highscores;
        string file = "highscores.xml";
        FileStream stream = File.Open(file, FileMode.OpenOrCreate, FileAccess.Read);
        try
        {
            XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
            highscores = (HighScoreData)serializer.Deserialize(stream);
        }
        finally
        {
            stream.Close();
        }
        return (highscores);
    }
}
